//
//  UITableView+CellAnimation.m
//  WHPersonalData
//
//  Created by shengmeng chen on 2022/12/8.
//  Copyright © 2022 mac. All rights reserved.
//

#import "UITableView+CellAnimation.h"

@implementation UITableView (CellAnimation)

-(void)shakeAnimationWithTableView {
    
    NSArray *cells = self.visibleCells;
    for (int i = 0; i < cells.count; i++) {
        UITableViewCell *cell = [cells objectAtIndex:i];
//        if (i%2 == 0) {
//            cell.transform = CGAffineTransformMakeTranslation(-ScreenW,0);
//        }else {
            //从右边出来
           // cell.transform = CGAffineTransformMakeTranslation(ScreenW,0);
        //}
        
        cell.transform = CGAffineTransformMakeTranslation(ScreenW,0);
        
        [UIView animateWithDuration:1 delay:i*0.03 usingSpringWithDamping:0.75 initialSpringVelocity:1/0.75 options:0 animations:^{
            cell.transform = CGAffineTransformIdentity;
        } completion:^(BOOL finished) {
            
        }];
    }
}

-(void)shakeAnimationWithTableViewFromTop {
    
    NSArray *cells = self.visibleCells;
    for (int i = 0; i < cells.count; i++) {
        UITableViewCell *cell = [cells objectAtIndex:i];
//        if (i%2 == 0) {
//            cell.transform = CGAffineTransformMakeTranslation(0,-s);
//        }else {
            //从右边出来
           // cell.transform = CGAffineTransformMakeTranslation(ScreenW,0);
        //}
        
        cell.transform = CGAffineTransformMakeTranslation(0,-ScreenH);
        
        [UIView animateWithDuration:1 delay:i*0.03 usingSpringWithDamping:0.75 initialSpringVelocity:1/0.75 options:0 animations:^{
            cell.transform = CGAffineTransformIdentity;
        } completion:^(BOOL finished) {
            
        }];
    }
}


@end
